feat: integrate background_task system into agents#5
Merged
Conversation
… unit tests - Add error logging to replace silent catch blocks (Task 2) - Add TTL-based cleanup to prevent memory leak (Task 3) - Add proper response types for API calls (Task 4) - Add comprehensive unit tests for BackgroundTaskManager (Task 5)
There was a problem hiding this comment.
1 issue found across 13 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="tests/tools/background-task-error-logging.test.ts">
<violation number="1" location="tests/tools/background-task-error-logging.test.ts:16">
P2: Test doesn't verify what its name claims. The assertion only checks that catch blocks have a named parameter, not that `console.error` is actually called. A catch like `.catch((err) => {})` would pass this test despite not logging anything. Consider parsing the full catch block body and verifying it contains `console.error`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…rage
- Add console.error to prompt session catch block
- Improve test to verify catch block bodies contain console.error
- Test now catches silent catch blocks like .catch((err) => {})
The blocking wait loop was checking a stale task object instead of re-fetching the current status, causing infinite hangs when block=true.
- Remove block and timeout params from background_output tool - Update executor, planner, project-initializer to use polling pattern - Poll with background_list, then collect with background_output - Simpler, more visible, no hanging
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/agents/project-initializer.ts">
<violation number="1" location="src/agents/project-initializer.ts:63">
P2: Polling instructions only check for "completed" status but don't account for tasks that may end in "error" state. This could cause the agent to poll indefinitely if any background task fails. Consider changing to: `Poll background_list until all tasks show "completed" or "error"`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…o-handoff to planner - Use background_task instead of Task for parallel codebase research - Fire-poll-collect pattern matches planner and executor - Auto-spawn planner when user approves design (no extra confirmation) - Add handoff phase for smooth transition to planning
- Commit after tests/types pass - Use commit message from plan - Stage only task-related files - Do not push (executor handles that)
- Brainstormer: uses background_task, auto-handoff to planner - Planner: library research tools (context7, btca_ask) - Executor: fire-and-check pattern with polling - Implementer: commits after verification - Tools: add btca_ask, document fire-poll-collect pattern
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="README.md">
<violation number="1" location="README.md:268">
P3: Documentation inconsistency: This states "All agents" use fire-poll-collect, but the executor section above documents that executor uses a different "fire-and-check" pattern. Consider changing to "Most agents" or "Research agents" to be accurate.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
vtemian
added a commit
that referenced
this pull request
Jan 3, 2026
- Remove block parameter from background_output, use polling pattern - Brainstormer: uses background_task for parallel research, auto-handoff to planner - Planner: fire-poll-collect pattern for research - Executor: fire-and-check pattern for parallel implementers/reviewers - Implementer: commits after verification passes - Project-initializer: fire-poll-collect for discovery - Fix stale task status bug in blocking loop - Add console.error to all catch blocks - Update README with new patterns
- Poll until tasks show 'completed' or 'error' (not just completed) - Skip errored tasks when collecting results - Fix README: clarify which agents use which pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Background Task System Fixes
progress.lastMessage(defined but never populated).catch(() => {})with properconsole.errorloggingAgent Prompt Updates
Testing
Design Document
See
thoughts/shared/designs/2026-01-01-background-task-integration-design.md(gitignored)Summary by cubic
Integrated the background_task system into executor, planner, project-initializer, and brainstormer for real async parallelism, and fixed stability issues in the task manager. This speeds up execution and prevents memory leaks and silent failures.
New Features
Bug Fixes
Written for commit ea234f7. Summary will update on new commits.